import Vue from 'vue'
/**权限指令**/
const has = Vue.directive('has', {
    // 当被绑定的元素插入到 DOM 中时……
    inserted: function (el, binding, vnode) {
        if (!Vue.prototype.$_has(binding.value)) {
            // el.parentNode.removeChild(el);
            el.style.display = 'none';
        }
    }
});
// 权限检查方法
Vue.prototype.$_has = function (value) {
    let isExist = false;
    let btnPermissionsStr = sessionStorage.getItem("btnPermissions");
    if (btnPermissionsStr === undefined || btnPermissionsStr === null) {
        return false;
    }
    if(btnPermissionsStr.includes(value)) {
        isExist =true;
    }
    return isExist;
};

export {has}

